﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace MyMusicPlay._4._0.Manager
{
    public class WindowsManage : ManagerBase
    {
        public static WindowsManage Manage;
        private Dictionary<Type, Window> _windows = new();

        public WindowsManage()
        {
            Manage = this;

            Init();
        }

        public void Init()
        {

        }

        public static T Find<T>() where T : Window, new()
        {
            if (!Manage._windows.ContainsKey(typeof(T)))
            {
                return Manage.Create<T>();
            }
            return Manage._windows[typeof(T)] as T;
        }

        public T Create<T>() where T : Window, new()
        {
            var window = new T();
            _windows.Add(typeof(T), window);
            return window;
        }

        public static bool Remove<T>() where T : Window
        {
            return Manage._windows.Remove(typeof(T));
        }
    }
}
